package xin.yangshuai.jvm01.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * HelloController
 *
 * @author shuai
 * @date 2022/2/11
 */
@RestController
public class HelloController {

    List<int[]> list = new ArrayList<>();

    @RequestMapping("memory")
    public Object outOfMemory() {

        for (int i = 0; i < 1000000; i++) {
            int[] array = new int[1024];
            list.add(array);
            System.out.println("------------------------------" + i);
        }
        return list;
    }


    @RequestMapping("memory1")
    public Object outOfMemory1() {

        List<int[]> list1 = new ArrayList<>();

        for (int i = 0; i < 1000000; i++) {
            int[] array = new int[1024];
            list1.add(array);
            System.out.println("------------------------------" + i);
        }
        return list1;
    }
}
